package com.feeyo.prophet.plugins;

import com.feeyo.llm.agent.engine.ActionResult;
import com.feeyo.llm.agent.engine.AttachObj;
import com.feeyo.llm.agent.engine.ResultScheme;

/**
 * 数据回复类型
 *
 * @author lihu
 */
public class AnswerUtils {

    /**
     * 数据直接回复
     *
     * @param action 行为
     * @param input  用户输入
     * @param data   数据
     * @return
     */
    public static ActionResult answer(String action, String input, String data) {
        ActionResult actionResult = new ActionResult(input, action, 200, data);
        return actionResult;
    }

    /**
     * 泛型测速
     */
    public static <T> ActionResult answer(String action, String input, T data, ResultScheme resultScheme) {
        ActionResult actionResult = new ActionResult(input, action, 200, data + "");
        actionResult.setResultScheme(resultScheme);
        return actionResult;
    }

    /**
     * 数据直接回复
     *
     * @param action 行为
     * @param input  用户输入
     * @param data   数据
     */
    public static ActionResult answer(String action, String input, String data, String description, Object barChart) {
        ActionResult actionResult = new ActionResult(input, action, 200, data);
        AttachObj attachObj = new AttachObj(AttachObj.Type.Chart, description, barChart);
        actionResult.putAttachObj(attachObj.getId(), attachObj);
        return actionResult;
    }

    /**
     * 直接指定类型回复
     *
     * @param action    action 类型
     * @param input     输入
     * @param attachObj 附加对象
     */
    public static <T> ActionResult directContentAnswer(String action, String input, AttachObj attachObj, T data) {
        ActionResult result = new ActionResult(input, action, 200, data + "");
        result.setReturnDirect(true);
        result.putAttachObj(attachObj.getId(), attachObj);
        return result;
    }


    public static <T> ActionResult directContentAnswer(String action, String input, AttachObj attachObj, T data, ResultScheme resultScheme) {
        ActionResult result = new ActionResult(input, action, 200, data + "");
        result.setResultScheme(resultScheme);
        result.setReturnDirect(true);
        result.putAttachObj(attachObj.getId(), attachObj);
        return result;
    }

    public static <T> ActionResult subContentAnswer(String action, String input, AttachObj attachObj, T data, ResultScheme resultScheme) {
        ActionResult result = new ActionResult(input, action, 200, data + "");
        result.setResultScheme(resultScheme);
        result.setReturnDirect(false);
        result.putAttachObj(attachObj.getId(), attachObj);
        return result;
    }

    public static <T> ActionResult subContentAnswer(String action, String input, AttachObj attachObj, T data) {
        ActionResult result = new ActionResult(input, action, 200, data + "");
        result.setReturnDirect(false);
        result.putAttachObj(attachObj.getId(), attachObj);
        return result;
    }
}